import request from '@/utils/request'
export const getMenu = (menu_name, parent_id) => {
  return request({
    url: 'api/selectMenu',
    method: 'get',
    params: {
      menu_name: menu_name,
      parent_id: parent_id,
    },
  })
}
export const selectRoleMenuByRoleId = role_id => {
  return request({
    url: 'api/selectRoleMenuByRoleId',
    method: 'get',
    params: {
      role_id: role_id,
    },
  })
}
export const getTreeMenu = () => {
  return request({
    url: 'api/selectTreeMenu',
    method: 'get',
  })
}
export const deleteMenu = menu_id => {
  return request({
    url: 'api/deleteMenu',
    method: 'delete',
    params: {
      menu_id: menu_id,
    },
  })
}
export const addMenu = menu => {
  return request({
    url: 'api/addMenu',
    method: 'put',
    data: menu,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}
export const editMenu = menu => {
  // console.log(menu);
  // console.log("================================");
  return request({
    url: '/api/editMenu',
    method: 'post',
    data: menu,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}
export const getRole = role_id => {
  return request({
    url: 'api/allRole',
    method: 'get',
    params: {
      role_id: role_id,
    },
  })
}
export const getUser = (username, role_id) => {
  return request({
    url: 'api/selectUserByUsername',
    method: 'get',
    params: {
      username: username,
      role_id: role_id,
    },
  })
}
export const saveUser = (user, roleId) => {
  return request({
    url: '/api/saveUser',
    method: 'post',
    data: user,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    params: {
      roleId: roleId,
    },
  })
}
export const deleteUser = user_id => {
  return request({
    url: 'api/deleteUser',
    method: 'delete',
    params: {
      user_id: user_id,
    },
  })
}
export const deleteUsers = users => {
  return request({
    url: 'api/deleteUsers',
    method: 'delete',
    data: users,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}
export const saveRoles = role => {
  return request({
    url: '/api/editRole',
    method: 'post',
    data: role,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}
export const addRole = (roleName, remark) => {
  return request({
    url: 'api/addRole',
    method: 'get',
    params: {
      roleName: roleName,
      remark: remark,
    },
  })
}
export const deleteRoleById = roleId => {
  return request({
    url: 'api/deleteRoleById',
    method: 'delete',
    params: {
      roleId: roleId,
    },
  })
}
